<?php

use yii\helpers\Html;
//use yii\bootstrap\ActiveForm;
use anruence\editormd\EditorMd;
use common\widgets\ueditor\Ueditor;
use yii\widgets\ActiveForm;
use janisto\timepicker\TimePicker;

?>

<div class='blog-form'>
    <?php $form = ActiveForm::begin([
        'options' => ['enctype' => 'multipart/form-data', 'id' => "news-flash-post"],]) ?>

    <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
    <?= $form->field($model, 'ishot')->radioList(['1' => '是', '0' => '否'])->label('热点快讯'); ?>
    <?= $form->field($model, 'content')->widget(Ueditor::className(), ['options'=>['lang' =>'zh-cn','initialFrameWidth' => '100%','initialFrameHeight' => 400]]);?>
    <?= $form->field($model, 'status')->radioList(['2' => '草稿', '3' => '定时发布', '0' => '立即发布'])->label('发布方式'); ?>
    <?= $form->field($model, 'ptime')->widget(TimePicker::className(), [
        //'language' => 'fi',
        'options' => ['placeholder' => 'Publish time','style' => 'width:300px;z-index:9999;'],
        'mode' => 'datetime',
        'clientOptions'=>[
            'dateFormat' => 'yy-mm-dd',
            'timeFormat' => 'HH:mm:ss',
            'showSecond' => true,
            'defaultTime' => date("H:i:s",time()),
            'minDate' => date("Y-m-d H:i:s",time())
        ]
    ])->label("发布时间");?>
    <span style="color: red;font-size: 12px;"><?= $msg;?></span>
    <div class='form-group field-blog-submit'>
        <?= Html::a('预览', ['/newsflash/viewbefore','data-id' => $model->id,'type' => 1], [
            'title' => Yii::t('yii', '提交前预览'),
            'class' => 'btn btn-default',
            'role' => 'modal-remote',
        ]) ?>
        <?= Html::submitButton($model->isNewRecord ? '确认发布' : '确认修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>
    <?php ActiveForm::end(); ?>
</div>
<script type="text/javascript">
    $(function(){
        $(".field-newsflash-ptime").hide();
        var _status = $("input[name='NewsFlash[status]']:checked").val();
        if( _status == 3 ){
            $(".field-newsflash-ptime").show();
        }
        $("input[name='NewsFlash[status]']").change(function () {
            if( $(this).val() == 3 ){
                $(".field-newsflash-ptime").show();
            }else{
                $(".field-newsflash-ptime").hide();
                $("#newsflash-ptime").val("");
            }
        });
    });
    

</script>


